package com.nopay.cdxphone.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;

import androidx.annotation.NonNull;

import com.nopay.cdxphone.R;

public class DialogHasNewVersion extends Dialog {

    private Activity mActivity;

    public DialogHasNewVersion(@NonNull Activity context) {
        super(context, R.style.MyDialog);
        mActivity = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_has_new_version);

        findViewById(R.id.tv_dialog_cancel).setOnClickListener(v -> dismiss());
        findViewById(R.id.tv_dialog_confirm).setOnClickListener(v -> {
            dismiss();
            if(onUpdateConfirmListener != null) onUpdateConfirmListener.onUpdateConfirm();
        });
    }

    private OnUpdateConfirmListener onUpdateConfirmListener;

    public DialogHasNewVersion setOnUpdateConfirmListener(OnUpdateConfirmListener onUpdateConfirmListener) {
        this.onUpdateConfirmListener = onUpdateConfirmListener;
        return this;
    }

    public interface OnUpdateConfirmListener {

        void onUpdateConfirm();
    }
}
